/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmRegisterBlock.java
 *
 * Created on 25/03/2010, 18:01:19
 */

package rad.Java.MotelPlus.Entries;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import rad.Java.Common.DB.Database;
import rad.Java.Common.Util.Functions;
import rad.Java.Common.Util.Constants;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import rad.Java.MotelPlus.Class.Apt;
import rad.Java.MotelPlus.Class.StateApt;
import rad.Java.MotelPlus.List.AptTypes;
import rad.Java.MotelPlus.List.Apts;
import rad.Java.MotelPlus.List.Blocks;
import rad.Java.Common.DB.Search;

/**
 *
 * @author rogerio
 */
public class frmRegisterApt extends javax.swing.JFrame {

    /** Creates new form frmRegisterBlock */
    public frmRegisterApt() {
        initComponents();

        buttons[0] = btnNew;
        buttons[1] = btnEdit;
        buttons[2] = btnSave;
        buttons[3] = btnDelete;
        buttons[4] = btnCancel;
        buttons[5] = btnExit;

        init();
        if( !resizeForm )
        {
            //this.MinimumSize = this.Size;
            //this.MaximumSize = this.Size;
        }

        _status = Constants.stBrowse;

        Functions.setButtons(buttons, _status);

        _title = this.getTitle(); //System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;


        if (!tabSearchVisible)
                    pnlSearch.setVisible(false);

        if (!tabMainVisible)
            pnlEdit.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlFrame = new javax.swing.JPanel();
        pnlDefaultButtons = new javax.swing.JPanel();
        btnNew = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();
        btnEdit = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        btnDelete = new javax.swing.JButton();
        btnExit = new javax.swing.JButton();
        pnlMain = new javax.swing.JPanel();
        tbpMain = new javax.swing.JTabbedPane();
        pnlSearch = new javax.swing.JPanel();
        lblSearch = new javax.swing.JLabel();
        txtSearch = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblMain = new javax.swing.JTable();
        btnSearch = new javax.swing.JButton();
        pnlEdit = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtNumber = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        cmbType = new javax.swing.JComboBox();
        cmbBlock = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(motelplus.MotelPlusApp.class).getContext().getResourceMap(frmRegisterApt.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setAlwaysOnTop(true);
        setLocationByPlatform(true);
        setName("Form"); // NOI18N

        pnlFrame.setName("pnlFrame"); // NOI18N
        pnlFrame.setLayout(new java.awt.BorderLayout());

        pnlDefaultButtons.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        pnlDefaultButtons.setMinimumSize(new java.awt.Dimension(341, 27));
        pnlDefaultButtons.setName("pnlDefaultButtons"); // NOI18N
        pnlDefaultButtons.setPreferredSize(new java.awt.Dimension(606, 70));
        pnlDefaultButtons.setRequestFocusEnabled(false);
        pnlDefaultButtons.setLayout(new java.awt.GridLayout(1, 0));

        btnNew.setIcon(resourceMap.getIcon("btnNew.icon")); // NOI18N
        btnNew.setToolTipText(resourceMap.getString("btnNew.toolTipText")); // NOI18N
        btnNew.setName("btnNew"); // NOI18N
        btnNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNewActionPerformed(evt);
            }
        });
        pnlDefaultButtons.add(btnNew);

        btnSave.setIcon(resourceMap.getIcon("btnSave.icon")); // NOI18N
        btnSave.setToolTipText(resourceMap.getString("btnSave.toolTipText")); // NOI18N
        btnSave.setName("btnSave"); // NOI18N
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });
        pnlDefaultButtons.add(btnSave);

        btnEdit.setIcon(resourceMap.getIcon("btnEdit.icon")); // NOI18N
        btnEdit.setToolTipText(resourceMap.getString("btnEdit.toolTipText")); // NOI18N
        btnEdit.setName("btnEdit"); // NOI18N
        btnEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditActionPerformed(evt);
            }
        });
        pnlDefaultButtons.add(btnEdit);

        btnCancel.setIcon(resourceMap.getIcon("btnCancel.icon")); // NOI18N
        btnCancel.setText(resourceMap.getString("btnCancel.text")); // NOI18N
        btnCancel.setToolTipText(resourceMap.getString("btnCancel.toolTipText")); // NOI18N
        btnCancel.setName("btnCancel"); // NOI18N
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });
        pnlDefaultButtons.add(btnCancel);

        btnDelete.setIcon(resourceMap.getIcon("btnDelete.icon")); // NOI18N
        btnDelete.setToolTipText(resourceMap.getString("btnDelete.toolTipText")); // NOI18N
        btnDelete.setName("btnDelete"); // NOI18N
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteActionPerformed(evt);
            }
        });
        pnlDefaultButtons.add(btnDelete);

        btnExit.setIcon(resourceMap.getIcon("btnExit.icon")); // NOI18N
        btnExit.setToolTipText(resourceMap.getString("btnExit.toolTipText")); // NOI18N
        btnExit.setName("btnExit"); // NOI18N
        btnExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExitActionPerformed(evt);
            }
        });
        pnlDefaultButtons.add(btnExit);

        pnlFrame.add(pnlDefaultButtons, java.awt.BorderLayout.SOUTH);

        pnlMain.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        pnlMain.setName("pnlMain"); // NOI18N
        pnlMain.setLayout(new java.awt.BorderLayout());

        tbpMain.setName("tbpMain"); // NOI18N

        pnlSearch.setName("pnlSearch"); // NOI18N

        lblSearch.setText(resourceMap.getString("lblSearch.text")); // NOI18N
        lblSearch.setName("lblSearch"); // NOI18N

        txtSearch.setName("txtSearch"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        tblMain.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tblMain.setName("tblMain"); // NOI18N
        jScrollPane1.setViewportView(tblMain);

        btnSearch.setText(resourceMap.getString("btnSearch.text")); // NOI18N
        btnSearch.setName("btnSearch"); // NOI18N
        btnSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlSearchLayout = new javax.swing.GroupLayout(pnlSearch);
        pnlSearch.setLayout(pnlSearchLayout);
        pnlSearchLayout.setHorizontalGroup(
            pnlSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlSearchLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlSearchLayout.createSequentialGroup()
                        .addComponent(txtSearch, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(btnSearch))
                    .addComponent(lblSearch))
                .addContainerGap())
        );
        pnlSearchLayout.setVerticalGroup(
            pnlSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlSearchLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblSearch)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSearch))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(15, Short.MAX_VALUE))
        );

        tbpMain.addTab(resourceMap.getString("pnlSearch.TabConstraints.tabTitle"), pnlSearch); // NOI18N

        pnlEdit.setName("pnlEdit"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        txtNumber.setText(resourceMap.getString("txtNumber.text")); // NOI18N
        txtNumber.setName("txtNumber"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        cmbType.setName("cmbType"); // NOI18N

        cmbBlock.setName("cmbBlock"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        javax.swing.GroupLayout pnlEditLayout = new javax.swing.GroupLayout(pnlEdit);
        pnlEdit.setLayout(pnlEditLayout);
        pnlEditLayout.setHorizontalGroup(
            pnlEditLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlEditLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlEditLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlEditLayout.createSequentialGroup()
                        .addGroup(pnlEditLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtNumber, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
                            .addComponent(jLabel1))
                        .addContainerGap(484, Short.MAX_VALUE))
                    .addGroup(pnlEditLayout.createSequentialGroup()
                        .addGroup(pnlEditLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlEditLayout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 195, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel4)
                            .addComponent(cmbBlock, 0, 228, Short.MAX_VALUE)
                            .addComponent(cmbType, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(376, 376, 376))))
        );
        pnlEditLayout.setVerticalGroup(
            pnlEditLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlEditLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cmbType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cmbBlock, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(85, Short.MAX_VALUE))
        );

        tbpMain.addTab(resourceMap.getString("pnlEdit.TabConstraints.tabTitle"), pnlEdit); // NOI18N

        pnlMain.add(tbpMain, java.awt.BorderLayout.CENTER);

        pnlFrame.add(pnlMain, java.awt.BorderLayout.LINE_START);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(pnlFrame, javax.swing.GroupLayout.PREFERRED_SIZE, 629, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(pnlFrame, javax.swing.GroupLayout.PREFERRED_SIZE, 396, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-647)/2, (screenSize.height-434)/2, 647, 434);
    }// </editor-fold>//GEN-END:initComponents

    // <editor-fold defaultstate="collapsed" desc="Buttons Methods">
    private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewActionPerformed
        _status = Constants.stInsert;
        Functions.setButtons(buttons, _status);
        Functions.clearForm(this);

        if(tbpMain.getSelectedIndex() != 1)
            tbpMain.setSelectedIndex(1);

        new_event();
}//GEN-LAST:event_btnNewActionPerformed

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
        boolean result;

        if( Functions.validateForm(this) && valid()) {
            setClass();
            //Save
            if( _status == Constants.stInsert ) {
                result = save();
            } else //Update
            {
                result = update();
            }


            if( result ) {
                JOptionPane.showMessageDialog(this, "Registro salvo com sucesso!",_title, JOptionPane.INFORMATION_MESSAGE);
                find();
                _status = Constants.stBrowse;
                Functions.setButtons(buttons, _status);
            } else {
                if (Database.ErrorMessage.contains("duplicate key violates unique constraint"))
                    JOptionPane.showMessageDialog(this, "Erro ao tentar salvar o registro:\nRegistro já existe!!!.",_title, JOptionPane.ERROR_MESSAGE);
                else
                    JOptionPane.showMessageDialog(this, "Erro ao tentar salvar o registro:\n"+Database.ErrorMessage,_title, JOptionPane.ERROR_MESSAGE);
                return;
            }
        }
}//GEN-LAST:event_btnSaveActionPerformed

    private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
        _status = Constants.stEdit;

        int index = tblMain.getSelectedRow();
        if (index >= 0) {
            Functions.clearForm(this);
            setEdits();
            tbpMain.setSelectedIndex(1);

            Functions.setButtons(buttons, _status);
        } else
            JOptionPane.showMessageDialog(this, "Por favor selecione um registro!", _title, JOptionPane.INFORMATION_MESSAGE);
        edit();
}//GEN-LAST:event_btnEditActionPerformed

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        _status = Constants.stBrowse;

        tbpMain.setSelectedIndex(0);
        Functions.clearForm(this);
        Functions.setButtons(buttons, _status);
}//GEN-LAST:event_btnCancelActionPerformed

    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
        int index = tblMain.getSelectedRow();
        if (index < 0) {
            JOptionPane.showMessageDialog(this, "Por favor selecione um registro!", _title, JOptionPane.WARNING_MESSAGE );
            return;
        }
        int dr = JOptionPane.showConfirmDialog(this, "Deseja realmente excluir o registro?",
                _title,
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE);

        if( dr == JOptionPane.YES_OPTION ) {
            if( delete() ) {
                JOptionPane.showMessageDialog(this, "Registro excluido com sucesso!", _title, JOptionPane.INFORMATION_MESSAGE);
                find();
            } else {
                if (Database.ErrorMessage.contains("violates foreign key constraint"))
                    JOptionPane.showMessageDialog(this,
                            "Erro ao tentar excluir o registro:\nRegistro já referenciado em outra tabela.",
                            _title, JOptionPane.ERROR_MESSAGE);
                else
                    JOptionPane.showMessageDialog(this,
                            "Erro ao tentar excluir o registro:\n"+Database.ErrorMessage,
                            _title, JOptionPane.ERROR_MESSAGE);
            }
        }
        _status = Constants.stBrowse;
        Functions.setButtons(buttons, _status);
}//GEN-LAST:event_btnDeleteActionPerformed

    private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
        exit();
        this.dispose();
}//GEN-LAST:event_btnExitActionPerformed

    private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchActionPerformed
        find();
}//GEN-LAST:event_btnSearchActionPerformed
// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Manual Methods">
    protected void new_event()
    {
        apt.clear();
    }

    protected boolean save()
    {
		return apt.save();
    }

    protected boolean update()
    {
		return apt.update();
    }

    protected boolean edit()
    {
        return true;
    }

    protected boolean delete()
    {
        apt.setId(tblMain.getValueAt(tblMain.getSelectedRow(), 0).toString());
        return apt.delete();
    }

    protected void exit()
    {

    }

    protected void init()
    {
        int i;
        listBlocks.fillList();
        listTypes.fillList();

        for(i=0; i < listBlocks.count(); i++)
            cmbBlock.addItem(listBlocks.get(i).getName());

        for(i=0; i < listTypes.count(); i++)
            cmbType.addItem(listTypes.get(i).getName());
    }

    protected void fillDataGridView()
    {
        try {
            int tam = 0;
            initTable();
            String[] data = new String[4];
            while (search.next()) {
                data[0] = search.getValue("apt_id").toString();
                data[1] = search.getValue("apt_number").toString();
                data[2] = search.getValue("apt_type_name").toString();
                data[3] = search.getValue("block_name").toString();
                dtmMain.addRow(data);
                
                if (search.isFirstRow()){
                    dtmMain.removeRow(0);
                }
            }
            tblMain.setModel(dtmMain);
            tblMain.repaint();
        } catch (SQLException ex) {
            Logger.getLogger(frmRegisterApt.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    protected void initTable()
    {
        String[] columns = new String[]{"Código", "Número", "Tipo", "Bloco"};
        String[][] data = new String[][]{{}};
        dtmMain = new DefaultTableModel(data, columns);
        tblMain.setModel(dtmMain);
    }

    protected void setEdits()
    {
        try {
            apt.setId(tblMain.getValueAt(tblMain.getSelectedRow(), 0).toString());            
            if (apt.get()) {
                txtNumber.setText(apt.getNumber());

                listBlocks.search(apt.getBlockId());
                cmbBlock.setSelectedIndex(listBlocks.getIndex());
                
                listTypes.search(apt.getTypeId());
                cmbType.setSelectedIndex(listTypes.getIndex());
            }
        } catch (SQLException ex) {
            Logger.getLogger(frmRegisterApt.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    protected void setClass()
    {
        apt.setNumber(txtNumber.getText());
        apt.setBlockId(listBlocks.get(cmbBlock.getSelectedIndex()).getId());
        apt.setTypeId(listTypes.get(cmbType.getSelectedIndex()).getId());

        //Se estiver adicionando um novo registro, então seta o status para livre
        if (apt.getId() == null ? "" == null : apt.getId().equals(""))
            apt.setStatus(StateApt.Livre);
    }

    protected void find()
    {
        search.prepare();
        search.setTable("apt");
        search.setFields("*");
        search.setTable("apt_type", "apt.apt_type_id = apt_type.apt_type_id");
        search.setTable("block", "apt_block_id = block_id");

        if( search.execute())
            fillDataGridView();
        else
            JOptionPane.showMessageDialog(this, "Erro ao efetuar busca:\n"+search.getMessageError(), "Erro", JOptionPane.ERROR_MESSAGE);
    }

    protected boolean valid()
    {
        return true;
    }
// </editor-fold>


    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new frmRegisterApt().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancel;
    public javax.swing.JButton btnDelete;
    public javax.swing.JButton btnEdit;
    public javax.swing.JButton btnExit;
    public javax.swing.JButton btnNew;
    public javax.swing.JButton btnSave;
    private javax.swing.JButton btnSearch;
    private javax.swing.JComboBox cmbBlock;
    private javax.swing.JComboBox cmbType;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblSearch;
    protected javax.swing.JPanel pnlDefaultButtons;
    private javax.swing.JPanel pnlEdit;
    private javax.swing.JPanel pnlFrame;
    protected javax.swing.JPanel pnlMain;
    private javax.swing.JPanel pnlSearch;
    private javax.swing.JTable tblMain;
    private javax.swing.JTabbedPane tbpMain;
    private javax.swing.JTextField txtNumber;
    private javax.swing.JTextField txtSearch;
    // End of variables declaration//GEN-END:variables

    protected  DefaultTableModel dtmMain;
    protected int _status;
    protected boolean  resizeForm = false;
    protected String _title;

    protected boolean tabSearchVisible = true;
    protected boolean tabMainVisible = true;
    protected JButton[] buttons = new JButton[6];

    private Apt apt = new Apt();
    private Apts list = new Apts();
    private Blocks listBlocks = new Blocks();
    private AptTypes listTypes = new AptTypes();
    private Search search = new Search();
}
